const session = require('koa-session');


const config = {
    key: "koa:sess",
    maxAge: 1000 * 60 * 60,
    autoCommit: true,
    overwrite: true,
    httpOnly: true, //服务端才能获取cookie
    signed: true, //默认签名
    rolling: false, //每次请求是否强行设置cookie，请重置cookie时间
    renew: false,
}

class Session {
    constructor() { }
    setSession(app) {
        return function (ctx, next) {
            if (ctx.setSession) {
                return next();
            }
            ctx.setSession = true;
            app.use(session(config, app));
            return next();
        }
    }

}

module.exports = config;